<template>
	<view class="home">
		<swiper class="swiper" :autoplay="true">
			<swiper-item v-for="(item,index) in technician.album" >
				<view class="swiper-item">
					<image :src="item" mode="aspectFit"></image>
				</view>
			</swiper-item>
		</swiper>
		<view class="flex-col">
			
			<view class="content-h1">
				<view v-for="(item,index) in 4" :key="index">
					<image src="../../../static/images/5@2x.png" mode=""></image>
					<text>{{ !index ? '实名认证' : index === 1 ? '头像认证' : index === 2 ? '健康证' : '按摩师证' }}</text>
				</view>
				<image class="r-icon" src="../../../static/images/9@2x.png" mode=""></image>
			</view>
			
			<view class="header">
				<image class="logo" :src="technician.avatar" mode="aspectFill"></image>
				<view class="right">
					<view class="right-2" style="display: flex;justify-content: space-between;">
						<div class="age">
							<view class="name">{{ technician.realname }}</view>	
							<view class="praise">评分<text>{{ technician.praise }}</text> </view>
						</div>
						<view class="right3">
							<view class="btn" style="font-size: 24rpx;" @click="changeCollect">{{ collect == 1 ? '取消收藏' : '收藏' }}</view>
							<view class="num">{{ technician.collect }}人收藏</view>
						</view>
						
					</view>
				</view>
			</view>
		</view>


			
		<view class="service">
			<view class="h1">
				<view v-for="(item,index) of tab.data" :class="index==tab.current?'active':''" @click.stop="changeTab(index)">
					{{item.title}}
				</view>
			</view>
			<view v-if="tab.current==0" class="product-wrapper content-p">
				<navigator class="product-item flex-row" :key="i" v-for="(item, i) in service"
					:url="`/pages/details/details?id=${item.id}&type=1&technician_id=${id}`">
					<view class="left-section flex-col">
						<view class="text-wrapper flex-col">
							<u--image :showLoading="true" :src="item.cover" width=" 216rpx" height="182rpx" radius="4"
								:fade="true" duration="450"></u--image>
							<text class="text_6">{{ item.label }}</text>
						</view>
					</view>
					<view class="right-group flex-col">
						<view class="flex-row justify-bw">
							<text class="text_8">{{ item.name }}</text>
						</view>
						<view class="group_8 flex-row">
							<image
								src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61ab188e1f655f0011bbaece/61e7d9270c0e3200129ec72c/16425844603777503649.png"
								class="image_5" />
							<text class="text_14">时长{{ item.duration }}分钟</text>
						</view>
						<view class="group_9 flex-row">
							<view class="left-group">
								<text class="text_16">￥</text>
								<text
									class="text_18 price-font">{{ item.price}}</text>
							</view>
							<view class="center-group flex-col">
								<view class="group_10">
									<text class="text_20">￥</text>
									<text class="text_22 price-font1">{{ item.original_price }}</text>
								</view>
								<view class="divider"> </view>
							</view>
							<view class="right-text-wrapper_1 flex-col items-center">
								<text>立即下单</text>
							</view>
						</view>
					</view>
				</navigator>
			</view>
			<view style="padding: 0 15px 8px; margin-top: 8px;" v-else>
				
				
				<view class="comment" v-for="item in comment">
					<view class="comment1 flex justify-between">
						<view class="flex">匿名用户<u-rate :value="item.service_score" :readonly="true"
								activeColor="#FF6100"></u-rate>
						</view>
						<view>{{item.create_time}}</view>
					</view>
					<view class="comment2">
						{{item.content}}
				
					</view>
					<view class="comment3 flex">
						<view v-for="item2 in item.name" class="comment3-item">
							{{item2}}
						</view>
					</view>
				</view>
				
				<view class="nodata" v-if="comment.length<1">暂无评价</view>

			</view>
		
		</view>
	</view>
</template>

<script>
	var that;
	export default {
		data() {
			return {
				id: '',
				technician: {
					"nickname": "",
					"realname": "",
					"avatar": "",
					"album": [],
					"praise": "",
					"sales": 0,
					"credit": -1,
					"service": "",
					"height": 0,
					"birthday": 0,
					"practice": 0,
					"profile": "0",
					"collect": 0,
					"province": ""
				},
				service: [],
				collect: "",
				comment: [],
				tab:{
					current:0,
					data:[
						{'title':'Ta的服务','action':'service'},
						{'title':'Ta的评价','action':'comment'},
					]
				},
			}
		},
		onLoad(options) {
			that=this;
			this.id = options.id;
			this.init();
		},
		methods: {
			async init() {
				let data = await this.$http.post('api/technician/details', {
					id: this.id
				});
				for (let i in data) {
					this[i] = data[i];
				}
			},
			changeCollect(){
				uni.showModal({
					content: that.collect == 1 ? '是否确认取消收藏？':'是否确认收藏？',
					success: (res) => {
						let { confirm } = res;
						if( confirm ){
							that.$http.post('api/collect/collect',{
								technician_id: that.id
							}).then(res =>{
								uni.showToast({
									icon:'success',
									title: that.that == 1 ? '取消成功' : '收藏成功'
								});
								that.collect == 1 ? that.collect = 0 : that.collect = 1;
								that.init();
							})
						}
					}
				})
			},
			changeTab(index){
				if(index==this.tab.current)
					return;
				this.tab.current=index;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.home {
		position: relative;

		.swiper {
			height: 300px;
			.swiper-item {
				height: 100%;
				image {
					margin: 0 auto;
					height: 100%;
				}
			}
		}

		.header {
			background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0, rgba(0, 0, 0, 0) 72rpx, rgba(255, 255, 255, 1));
			position: relative;
			z-index: 2;
			padding: 16rpx 20rpx;
			display: flex;
			align-items: center;
			.logo {
				width: 48px;
				height: 48px;
				flex-shrink: 0;
				border: 1 solid white;
				border-radius: 50%;
				overflow: hidden;
				box-sizing: border-box;
			}

			.right {
				margin-left: 16rpx;
				flex: 1;
				display: flex;
				flex-direction: column;
				
				&-1 {
					display: flex;
					align-items: center;
					flex: 1;
					margin-bottom: 24rpx;
					transform: translateY(24rpx);

					

					image {
						width: 90rpx;
						height: 36rpx;
						margin-left: 16rpx;
					}

				}

				&-2 {
					align-items: center;
					display: flex;
					color: rgba(80, 80, 80, 1);
					font-size: 28rpx;
					.sex {

						width: 40rpx;
						height: 40rpx;
						margin-right: 16rpx;
					}

					.age {
						position: relative;
						.name {
							color: white;
							font-size: 32rpx;
							color: #18b567;
							padding-right: 10rpx;
						}
						.praise>text{
							color: #ffaa00; margin-left: 2px;
						}
					}

					.age:nth-of-type(2) {
						margin: 0 48rpx;
					}

					.age:nth-of-type(2)::after {
						content: '';
						width: 2rpx;
						height: 16rpx;
						background-color: rgba(228, 228, 228, 1);
						position: absolute;
						top: 50%;
						transform: translateY(-50%);
						left: -24rpx;
					}

					.age:nth-of-type(2)::before {
						content: '';
						width: 2rpx;
						height: 16rpx;
						background-color: rgba(228, 228, 228, 1);
						position: absolute;
						top: 50%;
						transform: translateY(-50%);
						right: -24rpx;
					}

					.right3{
						    display: flex;
						    flex-direction: column;
						    align-items: center;
					}

					.btn {
						width: 128rpx;
						height: 48rpx;
						background: linear-gradient(143deg, rgb(56, 152, 124) 0%, #18B567 100%);
						border-radius: 48rpx;
						display: flex;
						align-items: center;
						justify-content: center;
						color: white;
					}
					
					.num {
						color: #18b567;
						flex: 1;
						text-align: right;
						
						font-size: 24rpx;
					}
				}
			}
		}

		.cont {
			display: flex;
			align-items: center;
			padding: 32rpx 32rpx 20rpx 32rpx;
			background-color: white;

			view:first-of-type {
				height: 44rpx;
				display: flex;
				align-items: center;
				padding: 0 10rpx;
				border: 2rpx solid rgba(24, 181, 103, 1);
				color: rgba(24, 181, 103, 1);
				font-size: 20rpx;
				box-sizing: border-box;
				text-align: center;
				border-radius: 8rpx;
				margin-right: 12rpx;
				width: 160rpx;
				justify-content: center;
			}

			view:last-of-type {
				color: rgba(102, 102, 102, 1);
				font-size: 28rpx;
			}
		}

		.content {
			background-color: white;
			margin-top: 24rpx;

			&-h1 {
				padding: 0 32rpx;
				height: 88rpx;
				display: flex;
				position: relative;

				.r-icon {
					position: absolute;
					width: 32rpx;
					height: 32rpx;
					top: 50%;
					transform: translateY(-50%);
					right: 32rpx;
				}

				view {
					display: flex;
					align-items: center;
					margin-right: 22rpx;

					image {
						width: 32rpx;
						height: 32rpx;
					}

					text {
						color: rgba(231, 190, 123, 1);
						font-size: 28rpx;
						margin-left: 4rpx;
					}
				}
			}

			&-h2 {
				display: flex;
				padding: 22rpx 32rpx 24rpx 32rpx;

				.view {
					flex: 1;
					background-color: rgba(24, 181, 103, 0.08);
					border-radius: 24rpx;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					padding:8px 0;
					view:first-of-type {
						color:rgb(56, 152, 124);
						font-size: 18px;
						font-weight: bold;

						text {
							font-size: 13px;
						}
					}

					view:last-of-type {
						font-size: 13px;
						color: rgba(80, 80, 80, 1);
					}
				}

				.view:nth-of-type(2) {
					margin: 0 24rpx;
				}
			}

			&-h3 {
				display: flex;
				flex-wrap: wrap;
				padding: 24rpx 32rpx;

				view {
					height: 56rpx;
					padding: 0 24rpx;
					background-color: rgba(24, 181, 103, .12);
					border-radius: 16rpx;
					margin-right: 24rpx;
					color: rgb(56, 152, 124);
					font-size: 28rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 24rpx;
				}

				.gayer {
					background-color: rgba(248, 248, 248, 1);
					color: rgba(153, 153, 153, 1);
				}
			}
		}

		.service {
			margin: 24rpx 0 32rpx;

			.h1 {
				display: flex;
				align-items: center;
				padding-left: 15px;
				justify-self:flex-start;
				padding-bottom: 8px;
			}
			.h1>view:nth-child(1){
				margin-right: 16px;
			}
			.h1 .active{
				position: relative;
			}
			.h1 .active::before{
				position: absolute;
				background-color: #18B567;
				height: 3.5px;
				content: ' ';
				width: 100%;
				bottom: -6px;
				border-radius: 3px;
			}

			.product-wrapper {
				.product-item {
					padding: 16rpx 22rpx 24rpx 24rpx;
					background-color: rgb(255, 255, 255);
					border-radius: 28rpx;
					margin: 20rpx 0;

					.left-section {
						//padding-top: 140rpx;
						color: rgb(255, 255, 255);
						font-size: 24rpx;
						line-height: 34rpx;
						white-space: nowrap;
						border-radius: 12rpx;
						//background-image: url('https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/61ab188e1f655f0011bbaece/61e7d9270c0e3200129ec72c/16425844604317986283.png');
						background-size: 100% 100%;
						background-repeat: no-repeat;
						width: 216rpx;
						height: 182rpx;

						.text-wrapper {
							padding: 13rpx 0 0 0;
							position: relative;

							.text_6 {
								text-align: center;
								width: 216rpx;
								position: absolute;
								bottom: 0;
								background-color: rgba(0, 0, 0, 0.36);
								border-radius: 0px 0px 12rpx 12rpx;
								//margin: 0 6rpx;
							}
						}
					}

					.right-group {
						margin-left: 24rpx;
						flex: 1 1 auto;

						.group_7 {
							margin-top: 8rpx;

							.left-text-wrapper {
								padding: 4rpx 0;
								color: rgb(255, 255, 255);
								font-size: 20rpx;
								line-height: 28rpx;
								white-space: nowrap;
								background-color: rgb(243, 151, 53);
								border-radius: 8rpx;
								width: 104rpx;
								height: 36rpx;
								text-align: center;
							}

							.right-text-wrapper {
								margin-left: 6rpx;
								padding: 2rpx 0;
								color: rgb(243, 151, 53);
								font-size: 20rpx;
								line-height: 28rpx;
								white-space: nowrap;
								border-radius: 8rpx;
								width: 104rpx;
								height: 36rpx;
								border: solid 2rpx rgb(243, 151, 53);
								text-align: center;
							}
						}

						.group_8 {
							margin-top: 8rpx;
							color: rgb(102, 102, 102);
							font-size: 24rpx;
							line-height: 34rpx;
							white-space: nowrap;

							.image_5 {
								width: 32rpx;
								height: 32rpx;
							}

							.text_14 {
								margin-left: 4rpx;
							}
						}

						.group_9 {
							margin-top: 16rpx;

							.left-group {
								margin-top: 14rpx;
								white-space: nowrap;
								height: 44rpx;

								.text_16 {
									color: rgb(255, 74, 74);
									font-size: 24rpx;
									line-height: 28rpx;
								}

								.text_18 {
									font-family: Price-Bold;
									color: rgb(255, 74, 74);
									font-size: 36rpx;
									line-height: 44rpx;
								}
							}

							.center-group {
								margin-left: 4rpx;
								margin-top: 20rpx;
								position: relative;

								.group_10 {
									line-height: 28rpx;
									white-space: nowrap;

									.text_20 {
										color: rgb(153, 153, 153);
										font-size: 24rpx;
										line-height: 28rpx;
									}

									.text_22 {

										color: rgb(153, 153, 153);
										font-size: 24rpx;
										line-height: 28rpx;
									}
								}

								.divider {
									background-color: rgb(151, 151, 151);
									width: 88rpx;
									height: 2rpx;
									position: absolute;
									left: 2rpx;
									right: 0;
									top: 50%;
									transform: translateY(-50%);
								}
							}

							.right-text-wrapper_1 {
								margin-left: 40rpx;
								color: rgb(255, 255, 255);
								font-size: 24rpx;
								line-height: 60rpx;
								white-space: nowrap;
								background-image: linear-gradient(112.4deg,
										rgb(56, 152, 124) 0%,
										rgb(56, 152, 124) -13.77%,
										rgb(56, 152, 124) 111.69%,
										rgb(56, 152, 124) 100%);
								border-radius: 20rpx;
								width: 128rpx;
								height: 60rpx;
								text-align: center;
							}
						}

						.text_8 {
							color: rgb(0, 0, 0);
							font-size: 32rpx;
							font-weight: 500;
							line-height: 44rpx;
							white-space: nowrap;
						}

						.text_10 {
							margin-bottom: 10rpx;
							color: rgb(153, 153, 153);
							font-size: 24rpx;
							line-height: 34rpx;
							white-space: nowrap;
							padding-right: 30rpx;
						}
					}
				}
			}
		}
	
	
		.comment {
			padding: 20rpx;
			background: #FFFFFF;
			color: #767676;
			border-radius: 18rpx;
			margin-bottom: 20rpx;
			font-size: 27rpx;
		
			.comment1 {
				font-size: 26rpx;
			}
		
			.comment2 {
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #767676;
				padding: 5rpx 0;
			}
		
			.comment3 {
				flex-wrap: wrap;
		
				.comment3-item {
					padding: 5rpx 20rpx;
					background: #EFEFEF;
					border-radius: 5rpx;
					margin-right: 16rpx;
					margin-top: 10rpx;
					color: #767676;
		
				}
			}
		}
		
		.nodata{
			margin: 32px; color: #333; text-align: center; font-size: 13px;
		}
	}
</style>
